package cn.gjculture.shopping.api.dao;


import cn.gjculture.shopping.api.entity.wx.PassiveMessage;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface PassiveMessageDao {

    @Insert("insert into passivemessage(id,title,picUrl,messageType,status,insertTime,updateTime) " +
            "values(#{id},#{title},#{picUrl},#{messageType},#{status},#{insertTime},#{updateTime})")
    int insert(PassiveMessage message);

    @Select("select * from passivemessage where id=#{id}")
    PassiveMessage queryById(String id);

    @Delete("delete from passivemessage where id=#{id}")
    int delete(String id);

    @Update("update passivemessage set `status`=1 where messageType=#{messageType}")
    int setInvalid(PassiveMessage message);

    @Update("update passivemessage set `status`=0 where id=#{id}")
    int setValid(PassiveMessage message);

    @Select("select * from passivemessage where `status`=#{status} and messageType=#{messageType}")
    PassiveMessage queryValidMessage(PassiveMessage passiveMessage);
}
